package com.kinth.common;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kinth.rest.api.CreateEmailInfoRequest;
  
/** 
 * 微信自定义菜单创建 
 */  
public class HttpUtil {  
	
    // http客户端  
    public static DefaultHttpClient httpclient;

    static {  
        httpclient = new DefaultHttpClient();  
    }  
    

    /**
	 * 发送模板消息，主动给用户发消息
	 * @param result
	 * @return
	 * @throws Exception
	 */
	public static String save(CreateEmailInfoRequest info) throws Exception {
		

		JSONObject in = new JSONObject();
		in.put("address", info.getAddress());
		in.put("company", info.getCompany());
		in.put("username", info.getUsername());
		in.put("email", info.getEmail());
		in.put("phone1", info.getPhone1());
		in.put("phone2", info.getPhone2());
		in.put("phone3", info.getPhone3());
		in.put("industry", info.getIndustry());
		in.put("area", info.getArea());
		in.put("remark", info.getRemark());
		in.put("url", info.getUrl());
		in.put("product", info.getProduct());
		in.put("introduce", info.getIntroduce());
		in.put("source", info.getSource());
		
		HttpPost httpost = HttpClientConnectionManager
				.getPostMethod("http://data.kinthtech.com/api/v1.0/company/spider-data-insert.json");
		httpost.setEntity(new StringEntity(in.toString(), "UTF-8"));
		HttpResponse response = httpclient.execute(httpost);
		String jsonStr = EntityUtils.toString(response.getEntity(), "utf-8");
		//System.out.println("OK:"+jsonStr);
//		JSONObject object = JSON.parseObject(jsonStr);
		return null;
	}
	
      
}